//
//  DetailViewController.m
//  OtakuWorld
//
//  Created by iOS Two on 14-9-22.
//  Copyright (c) 2014年 iOS Two. All rights reserved.
//

#import "DetailViewController.h"

@interface DetailViewController ()

@end

@implementation DetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)viewWillAppear:(BOOL)animated {
    [MobClick beginLogPageView:@"DetailViewController"];
}
-(void)viewWillDisappear:(BOOL)animated {
    [MobClick endLogPageView:@"DetailViewController"];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    if (version >= 7) {
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"112_01"] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    } else {
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"112_01"] forBarMetrics:UIBarMetricsDefault];
    }
    UIBarButtonItem *back = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"backAR"] style:UIBarButtonItemStyleDone target:self action:@selector(buttonClick)];
    [self.navigationController.navigationBar setTintColor:[UIColor colorWithRed:0.99 green:0.62 blue:0.27 alpha:1]];
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    negativeSpacer.width = 0;
    self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacer, back, nil];
    
    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    [appDelegate.leveyTabBarController hidesTabBar:YES animated:YES];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(120, 7, 100, 20)];
    label.text = @"详细信息";
    label.textColor = [UIColor colorWithRed:0.99 green:0.62 blue:0.27 alpha:1];
    label.font = [UIFont fontWithName:@"STXIHEI" size:20];
    [label sizeToFit];
    self.navigationItem.titleView = label;
    
    _web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, kHeight - 64)];
    NSURLRequest *request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://mrobot.pcgames.com.cn/v3/cms/articles/%@?size=18&template=(null)",_url]]];
    [_web loadRequest:request];
    _web.delegate = self;
    [self.view addSubview:_web];
    // Do any additional setup after loading the view.
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
    [self showIndeterminateProgress];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [HUD hide:YES];
}
-(void)buttonClick {
    if (version >= 7) {
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"qwe_02"] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    } else {
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"qwe_02"] forBarMetrics:UIBarMetricsDefault];
    }
    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    [appDelegate.leveyTabBarController hidesTabBar:NO animated:YES];
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
